package model.bll;

import java.util.List;

import model.dal.AbstractDAL;
import model.entity.GenericEntity;

public abstract class AbstractBLL<E extends GenericEntity> implements GenericBLL<E> {

	private AbstractDAL<E> abstractDAL;

	public AbstractBLL(AbstractDAL<E> abstractDAL) {
		this.abstractDAL = abstractDAL;
	}

	public boolean insertEntity(E entity) {
		boolean result = false;
		if (validateEntity(entity)) result = abstractDAL.insertEntity(entity);
		return result;
	}

	public boolean updateEntity(E entity) {
		boolean result = false;
		if (validateEntity(entity)) result = abstractDAL.updateEntity(entity);
		return result;
	}

	public boolean deleteEntity(E entity) {
		return abstractDAL.deleteEntity(entity);
	}

	public List<E> getAllEntity() {
		return abstractDAL.getAllEntity();
	}

	public E findEntityById(long id) {
		return abstractDAL.findEntityById(id);
	}

}
